package deployr.core;

import java.util.*;

public class Parameters {

	private Map<String, String> parameters = new HashMap<String, String>();
	
	public Parameters(String[] args) {
		setParameters(args);
	}

	private void setParameters(String[] args) {
		checkParameters(args);
		mapParameters(args);
	}

	private void mapParameters(String[] args) {
		for (int k = 1; k < args.length; k += 2) {
			parameters.put(args[k].replaceAll("-", ""), args[k + 1]);
		}
	}

	private void checkParameters(String[] args) {
		if ((args.length -1) % 2 == 1) throw new RuntimeException("wrong parameters");
	}

	public Option getParameter(String name) {
		return new Option(parameters.get(name));
	}

}
